// UVa11988 Broken Keyboard (a.k.a. Beiju Text)
// 陈锋
#include <bits/stdc++.h>
using namespace std;
int main() {
  for (string line; cin >> line; cout << endl) {
    list<char> l;
    auto pos = l.begin();
    for (char c : line) {
      if (c == '[')
        pos = l.begin();
      else if (c == ']')
        pos = l.end();
      else
        l.insert(pos, c);
    }
    for (char c : l) cout << c;
  }
  return 0;
}
/*
算法分析请参考: 《入门经典-第2版》例题6-4
注意本题中对STL中基于双向链表的容器list以及list::iterator的使用
*/
// 24467246 11988 Broken Keyboard (a.k.a. Beiju Text) Accepted  C++11 0.200
// 2020-01-25 09:39:04